package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class BorrowOperation implements IOPeration{
    @Override
    public void work(BookList bookList) {
        System.out.println("借阅图书");

        System.out.println("需要借阅的书籍名称为：");
        Scanner sc = new Scanner(System.in);
        String bookName = sc.nextLine();

        int number = bookList.getUsedSize();
        for(int i = 0; i < bookList.getUsedSize(); i++){
            Book book = bookList.getBook(i);
            if(book.getName().equals(bookName)) {
                book.setLend(true);
                System.out.println("借阅成功");
                return;
            }
        }
        System.out.println("借阅失败");
    }
}
